//----------------------------------*-C++-*----------------------------------//
/*!
 * \file   InputDB.hh
 * \author Jeremy Roberts
 * \date   Sep 8, 2011
 * \brief  InputDB class definition.
 * \note   Copyright (C) 2011 Jeremy Roberts. 
 */
//---------------------------------------------------------------------------//
// $Rev::                                               $:Rev of last commit
// $Author:: j.alyn.roberts@gmail.com                   $:Author of last commit
// $Date::                                              $:Date of last commit
//---------------------------------------------------------------------------//

#ifndef INPUTDB_HH_
#define INPUTDB_HH_

#include <iostream>
#include <string>
#include <map>

namespace slabtran
{

//===========================================================================//
/*!
 * \class InputDB
 * \brief Flexible storage for user input.
 *
 * User input for transport codes typically involves several integer and
 * scalar quantities along with meshing, materials data, and materials
 * placement.  For the former quantities, it can be a bonafide pain in the
 * arse to maintain an input structure throughout development.  To avoid that
 * issue, we use C++ maps of type int and double to store anything the user
 * needs to put there for use anywhere in the code.  This is inspired by the
 * way Denovo handles input.  For us, a descendent of Parser will read some
 * form of user input (be it XML or SILO or HDF5) and fill an InputDB along
 * with generating other things (like the data needed to make meshes and
 * materials libraries).  Of course, some parameters need to be there, and
 * that can be checked during a verification.
 *
 * (It's anticipated this will become a serment-wide approach)
 *
 */

class InputDB
{

public:

  /*
   *  \brief Constructor.
   */
  InputDB();

  /// \name Accessors
  //\{

  /*
   *  \brief Return value of key
   *  \param    key     Name of the parameter.
   *  \param    value   Reference to which parameter value is assigned.
   *  \return           Check whether key is found.
   */
  template <typedef T>
  bool get(const std::string &key, T &value) const;

  /*
   *  \brief Put a key and value in the database.
   *  \param    key         Name of the parameter.
   *  \param    value       Reference to which parameter value is assigned.
   *  \param    replace     Can we replace a current value?
   *  \return               Check whether key is found.
   */
  template <typedef T>
  bool put(const std::string &key, const T value, bool replace = true);

  //\}

  /*
   *  \brief Verify the input database is complete.
   *
   *  This is probably the only place where upkeep needs to occur.  There
   *  may be an intelligent way to do it, something like a "grammar".
   *
   *  \return Whether or not verification was successful.
   */
  bool verify();

private:

  /// \name Data
  //\{

  /// Integer parameters.
  std::map<int> d_data_int;

  /// Double parameters.
  std::map<double> d_data_double;

  //\}

  /// \name Implementation
  //\{

  //\}

};


} // end namespace slabtran

#endif /* INPUTDB_HH_ */

//---------------------------------------------------------------------------//
//              end of InputDB.hh
//---------------------------------------------------------------------------//
